<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>创建一个函数式组件</title>
    <meta name="description" content="">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="">
</head>

<body>
    <!--准备好一个容器-->
    <div id="test"></div>
    <!--引入react核心库,核心库必须先引入-->
    <script type="text/javascript" src="./js/react.development.js"></script>
    <!--引入react-dom, 用于支持react操作DOM-->
    <script type="text/javascript" src="./js/react-dom.development.js"></script>
    <!--引入babel,用于将jsx转为js-->
    <script type="text/javascript" src="./js/babel.min.js"></script>

    	<!-- 引入prop-types，用于对组件标签属性进行限制 -->
	<script type="text/javascript" src="./js/prop-types.js"></script>

    <script type="text/babel">
            function Init(props) {
                return(
                  <div>
                    <h2>{props.name}</h2>
                    <h2>{props.sex}</h2>
                    <h2>{props.age}</h2>
                 </div>
                )
            }

              //对标签属性进行类型，必要性的限制
            Init.propTypes = {
			name:PropTypes.string.isRequired, //限制name必传，且为字符串
			sex:PropTypes.string,//限制sex为字符串
			age:PropTypes.number,//限制age为数值
		}

             //指定默认标签属性值
             Init.defaultProps ={
                sex:"女",
                age:18, //不传时的默认值
             }
    

   ReactDOM.render(<Init name="邓紫棋"/>,document.getElementById('test'))

    </script>




</body>

</html>